;;;Dialog interface for deleting drawing log entries created in a drawing using (log_it) from log_it.lsp
;;;
;;;	AUTHOR: HENRY C. FRANCIS
;;;		425 N. ASHE ST.
;;;		SOUTHERN PINES, NC 28387
;;;
;;;		All rights reserved without prejudice.
;;;
;;;	Copyright:	9-20-2010
;;;	Edited:		9-20-2010
;;;
;;;****************************************************************************
(DEFUN c:editlog (/ del_key)
  (SETQ editlog_num (LOAD_DIALOG "editlog"))
  (NEW_DIALOG "editlog" editlog_num
           (IF defact_editlog
             defact_editlog
             ""
           ) ;_ end of IF
           (IF editlog_loc
             editlog_loc
             '(-1 -1)
           ) ;_ end of IF
  )
  (MODE_TILE "log_dates" 2)
  (ACTION_TILE
    "log_dates"
    "(setq del_key (get_tile\"log_dates\"))(show_fname)"
  ) ;_ end of ACTION_TILE
  (ACTION_TILE
    "Delete_date"
    "(setq del_key (get_tile\"log_dates\"))(delete_logdate)";(setq editlog_loc (done_dialog 1))"
  ) ;_ end of ACTION_TILE
  (ACTION_TILE "Add_cancel" "(setq editlog_loc (done_dialog 0))")
  (set_editlog_list)
  (START_DIALOG)
  (COND	;((AND del_key (/= del_key "")) (delete_logdate))
        (T (PRINC "\nFunction cancelled! ")
          (PRINC "\ndel_key =")(PRINC del_key)(PRINC)
        )
  ) ;_ end of COND
  (UNLOAD_DIALOG editlog_num)
  (PRINC)
) ;_ end of DEFUN
;;;**************************************************************************************************
(DEFUN set_editlog_list ()
  (IF vlax-ldata-get NIL (VL-LOAD-COM))
  (setq logit_ldata (vlax-ldata-get "logit_data" "dwgedit_data"))
  (IF logit_ldata
    (PROGN
      (SETQ log_dates (MAPCAR 'EVAL (MAPCAR '(LAMBDA (y) (CONS 'STRCAT y))(MAPCAR '(LAMBDA (x) (MAPCAR '(LAMBDA (y) (STRCAT (CDR y) " "))x)) logit_ldata))))
      (START_LIST "log_dates")
      (MAPCAR 'ADD_LIST log_dates)
      (END_LIST)
    )
    (IF
      (SETQ logss (SSGET "x" (LIST '(-3 ("CORP")) (CONS 2 "DWG-EDIT-LOG"))))
      (PROGN
        (IF log_it NIL (LOAD "log_it" "\nFile LOG_IT.LSP not loaded! "))
        (log_it)
        (SETQ log_dates (MAPCAR 'EVAL (MAPCAR '(LAMBDA (y) (CONS 'STRCAT y))(MAPCAR '(LAMBDA (x) (MAPCAR '(LAMBDA (y) (STRCAT (CDR y) " "))x)) logit_ldata))))
        (START_LIST "log_dates")
        (MAPCAR 'ADD_LIST log_dates)
        (END_LIST)
      )
      (SET_TILE "error" "No log entries exist in this drawing.")
    )
  )
  (PRINC)
)
;;;**************************************************************************************************
(DEFUN show_fname ()
  (SETQ this_name (NTH (ATOI del_key) logit_ldata))
  (SET_TILE "error" (STRCAT (CDR (NTH 4 this_name))(CDR (NTH 3 this_name))))
  (PRINC)
)
;;;**************************************************************************************************
(DEFUN delete_logdate ()
  (SETQ ndx (ATOI del_key))
  (SETQ ldata_part1 logit_ldata
        ldata_part2 logit_ldata
  )
  (WHILE (AND (MEMBER (NTH ndx logit_ldata) (REVERSE ldata_part1)) (>(LENGTH ldata_part1) 1))
    (SETQ ldata_part1 (REVERSE (CDR (MEMBER (NTH ndx logit_ldata) (REVERSE ldata_part1)))))
  )
  (WHILE (AND (MEMBER (NTH ndx logit_ldata) (REVERSE ldata_part2)) (>(LENGTH ldata_part2) 1))
    (SETQ ldata_part2 (CDR (MEMBER (NTH ndx logit_ldata) ldata_part2)))
  )
  (SETQ new_logit_ldata
         (APPEND ldata_part1
                 ldata_part2
         )
  )
  (SETQ cnt 0
        new_log_dates NIL
  )
  (WHILE (< cnt (LENGTH log_dates))
    (IF (EQ cnt ndx)
      NIL
      (SETQ new_log_dates (APPEND new_log_dates (LIST (NTH cnt log_dates))))
    )
    (SETQ cnt (1+ cnt))
  )
  (SETQ log_dates new_log_dates)
  (START_LIST "log_dates")
  (MAPCAR 'ADD_LIST log_dates)
  (END_LIST)
  (setq logit_ldata (vlax-ldata-put "logit_data" "dwgedit_data" new_logit_ldata))
  (PRINC)
)
;;;****************************************************************************
